<template>
  <div class="windowStaff">
    <el-dialog title="选择窗口人员" :visible="dialogVisible" @close="handleClose">
      <div class="staffBlock">
        <div @click="chooseStaff(item.id, index)" :class="['windowStaff', currentIndex == index ? 'checked' : '']" v-for="(item, index) in staffList" :key="index">
          <div class="leftTop">{{ item.window | windowType }}</div>
          <div class="pa-flex pa-mt-1">
            <img class="img" :src="item.headPortrait" alt="" />
            <div>
              <div :class="['pa-mb-1', currentIndex == index ? 'checkedColor' : 'staff']">{{ item.realname }}</div>
              <div :class="['pa-mb-1', currentIndex == index ? 'phoneColor' : 'phone']">联系方式:{{ item.mobile }}</div>
            </div>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="cancel" plain @click="handleClose">取 消</el-button>
        <el-button class="sure" @click="makeSure">确认</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { getAssistantApi } from '@/api/manageApi.js'
export default {
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      staffList: [],
      currentIndex: -1,
      windowId: ''
    }
  },
  filters: {
    windowType(val) {
      switch (val) {
        case 0:
          return '宁波市生态环境局镇海分局'
        case 1:
          return '宁波市自然资源和规划局镇海分局'
        case 2:
          return '宁波石化开发区产业发展局'
        case 3:
          return '区应急管理局'
        case 4:
          return '区住房和建设交通局'
        case 5:
          return '宁波石化开发区产业发展局'
        case 6:
          return '区经济和信息化局'
        case 7:
          return '区住房和建设交通局'
        case 8:
          return '区农业农村局'
        case 9:
          return '区发展和改革局'
        case 10:
          return '区应急管理局'
        case 11:
          return '区文化和广电旅游体育局'
        case 12:
          return '区经济和信息化局'
        case 13:
          return '区综合行政执法局'
        case -1:
          return '全部'
      }
    }
  },
  mounted() {
    this.getAssistant()
  },
  methods: {
    handleClose() {
      this.$emit('update:dialogVisible', false)
    },
    makeSure() {
      this.$emit('makeSure', this.windowId)
    },
    chooseStaff(id, index) {
      this.windowId = id
      this.currentIndex = index
    },
    // 查询窗口人员
    getAssistant() {
      getAssistantApi({}).then(res => {
        if (res.code == 0) {
          this.staffList = res.data
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.windowStaff {
  .staffBlock {
    width: 520px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-row-gap: 26px;
    grid-column-gap: 30px;
  }
  ::v-deep .dialog-container .el-dialog__body {
    padding-bottom: 20px;
  }
  ::v-deep .el-dialog {
    width: 587px !important;
  }
  ::v-deep .el-dialog__body {
    max-height: 390px;
    overflow: auto;
  }

  .cancel {
    width: 85px;
    height: 48px;
    border: 1px solid #2b80ff;
    border-radius: 5px;
    color: #2b80ff;
    padding: 0;
  }
  .sure {
    width: 85px;
    height: 48px;
    background: #2b80ff;
    border-radius: 5px;
    color: #fff;
    padding: 0;
  }
  .checked {
    background: #4880ff !important;
  }
  .checkedColor {
    font-size: 20px;
    font-weight: bold;
    color: #fff;
  }
  .windowStaff {
    width: 245px;
    height: 106px;
    background: #ffffff;
    border: 1px solid #4880ff;
    border-radius: 10px;
    cursor: pointer;
    .leftTop {
      // width: 79px;
      height: 29px;
      line-height: 29px;
      text-align: center;
      background: #c2dafe;
      border-radius: 10px 0 10px 0;
      color: #4880ff;
    }
    .img {
      width: 48px;
      height: 48px;
      margin-left: 11px;
      margin-right: 4px;
    }
    .staff {
      font-size: 20px;
      font-weight: bold;
      color: #333333;
    }
    .phone {
      color: #999999;
    }
    .phoneColor {
      color: #fff;
    }
  }
}
</style>
